<%--
  Created by IntelliJ IDEA.
  User: Yang
  Date: 2021/11/26
  Time: 8:27
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>

<html>
<head>
    <%@include file="common/devhead.jsp"%>>
</head>
<body style="background-color:white" class="nav-md">
<div class="container body">
    <%--    class="container-fluid"--%>
    <div style="padding-right: 15px;
    padding-left: 259px;
    margin-right: auto;
    margin-left: auto;">
        <div class="clearfix"></div>
        <div class="row">
            <div class="col-md-12 col-sm-12 col-xs-12">
                <div class="x_panel">
                    <div class="x_title">
                        <h2>新增APP版本信息 <i class="fa fa-user"></i><small>${userSession.devName}</small></h2>
                        <div class="clearfix"></div>
                    </div>
                    <div class="x_title">
                        <h2>历史版本列表</h2>
                        <div class="clearfix"></div>
                    </div>
                    <div class="x_content1">
                        <div class="clearfix"></div>
                        <p class="text-muted font-13 m-b-30"></p>
                        <div id="datatable-responsive_wrapper"
                             class="dataTables_wrapper form-inline dt-bootstrap no-footer">
                            <div class="row">
                                <div class="col-sm-12">
                                    <table id="datatable-responsive" class="table table-striped table-bordered dt-responsive nowrap dataTable no-footer dtr-inline collapsed"
                                           cellspacing="0" width="100%" role="grid" aria-describedby="datatable-responsive_info" style="width: 100%;">
                                        <thead>
                                        <tr role="row">
                                            <th class="sorting_asc" tabindex="0"
                                                aria-controls="datatable-responsive" rowspan="1" colspan="1"
                                                style="width: 70px;" aria-label="First name: activate to sort column descending"
                                                aria-sort="ascending">软件名称</th>
                                            <th class="sorting" tabindex="0"
                                                aria-controls="datatable-responsive" rowspan="1" colspan="1"
                                                style="width: 10px;"
                                                aria-label="Last name: activate to sort column ascending">
                                                版本号</th>
                                            <th class="sorting" tabindex="0"
                                                aria-controls="datatable-responsive" rowspan="1" colspan="1"
                                                style="width: 90px;"
                                                aria-label="Last name: activate to sort column ascending">
                                                版本大小(单位:M)</th>
                                            <th class="sorting" tabindex="0"
                                                aria-controls="datatable-responsive" rowspan="1" colspan="1"
                                                style="width: 50px;"
                                                aria-label="Last name: activate to sort column ascending">
                                                发布状态</th>
                                            <th class="sorting" tabindex="0"
                                                aria-controls="datatable-responsive" rowspan="1" colspan="1"
                                                style="width: 50px;"
                                                aria-label="Last name: activate to sort column ascending">
                                                APK文件下载</th>
                                            <th class="sorting" tabindex="0"
                                                aria-controls="datatable-responsive" rowspan="1" colspan="1"
                                                style="width: 50px;"
                                                aria-label="Last name: activate to sort column ascending">
                                                最新更新时间</th>
                                        </tr>
                                        </thead>
                                        <tbody>
                                        <c:forEach var="appVersion" items="${versionList}" varStatus="status">
                                            <tr role="row" class="odd">

                                                <td tabindex="0" class="sorting_1">${appVersion.softwareName}</td>
                                                <td>${appVersion.versionNo}</td>
                                                <td>${appVersion.versionSize}</td>
                                                <td>${appVersion.pulishStatusName }</td>
                                                <td>
                                                    <a href="${appVersion.downloadLink }">${appVersion.apkFileName }</a>
                                                </td>
                                                <td><fm:formatDate value="${appVersion.modifyDate }" pattern="yyyy-MM-dd"/></td>
                                            </tr>
                                        </c:forEach>
                                        </tbody>
                                    </table>
                                </div>
                            </div>
                        </div>
                        <div class="clearfix"></div>
                        <div class="x_title">
                            <h2>修改版本信息</h2>
                            <ul class="nav navbar-right panel_toolbox">
                                <li><a class="collapse-link"><i class="fa fa-chevron-up"></i></a>
                                </li>
                            </ul>
                            <div class="clearfix"></div>
                        </div>
                        <div class="x_content" style="display: block;">
                            <br>
                            <form class="form-horizontal form-label-left" action="${pageContext.request.contextPath}/appInfo/upAppVersion" method="post" enctype="multipart/form-data">
                                <input type="hidden" name="appId" value="${appIdd}">
                                <input type="hidden" name="id" value="${version.id}">
                                <div class="item form-group">
                                    <label class="control-label col-md-3 col-sm-3 col-xs-12" >版本号 <span class="required">*</span>
                                    </label>
                                    <div class="col-md-6 col-sm-6 col-xs-12">
                                        <input id="versionNo" class="form-control col-md-7 col-xs-12"
                                               data-validate-length-range="20" data-validate-words="1" name="versionNo"
                                               placeholder="请输入版本号" readonly="readonly" type="text" value="${version.versionNo}" required="required">

                                    </div>
                                </div>
                                <div class="item form-group">
                                    <label class="control-label col-md-3 col-sm-3 col-xs-12" >版本大小 <span class="required">*</span>
                                    </label>
                                    <div class="col-md-6 col-sm-6 col-xs-12">
                                        <input type="number" id="versionSize" name="versionSize"  required="required"
                                               data-validate-minmax="10,500" value="${version.versionSize}"  placeholder="请输入版本大小，单位为Mb" class="form-control col-md-7 col-xs-12">
                                    </div>
                                </div>

                                <div class="item form-group">
                                    <label class="control-label col-md-3 col-sm-3 col-xs-12" >发布状态 <span class="required">*</span></label>
                                    <div class="col-md-6 col-sm-6 col-xs-12">
                                        <input type="hidden" name="publishStatus" id="publishStatus" value="3">预发布
                                    </div>
                                </div>

                                <div class="item form-group">
                                    <label class="control-label col-md-3 col-sm-3 col-xs-12" >版本简介 <span class="required">*</span>
                                    </label>
                                    <div class="col-md-6 col-sm-6 col-xs-12">
              <textarea id="versionInfo" name="versionInfo" required="required"
                        placeholder="请输入本版本的相关信息，本信息作为该版本的详细信息进行版本介绍。" class="form-control col-md-7 col-xs-12">${version.versionInfo}</textarea>
                                    </div>
                                </div>
                                <div class="item form-group">
                                    <label class="control-label col-md-3 col-sm-3 col-xs-12" >apk文件 <span class="required">*</span>
                                    </label>
                                    <div class="col-md-6 col-sm-6 col-xs-12">
                                        <span class="ssa">${version.apkFileName}</span>
                                        <a href="javascript:;" onclick="bbb('${version.apkFileName}',${version.id},${downloads})" class="col-md-offset-1" >下载</a>
                                        <a href="javascript:;" class="apkdel" id="${version.id}">删除</a>
                                        <input type="file" style="display: none" class="form-control col-md-7 col-xs-12" name="download"  required="required"/>
                                        ${fileUploadError }
                                    </div>
                                </div>
                                <div class="ln_solid"></div>
                                <div class="form-group">
                                    <div class="col-md-6 col-md-offset-3">
                                        <button id="send" type="submit" class="btn btn-success">保存</button>
                                        <a href="${pageContext.request.contextPath}/appInfo/devlist" class="btn btn-primary">返回</a>
                                    </div>
                                </div>
                            </form>
                        </div>
                    </div>
                </div>
            </div>
        </div>

    </div>
</div>
</body>
<%@include file="common/devfoot.jsp"%>
<script>
    var backBtn=null;
    var path='${pageContext.request.contextPath}';
    $(".apkdel").click(function(){
        var id=this.id;
        $.getJSON(path+"/appInfo/delApk/"+id,"",function (data){
            if (data){
                $("[name=download]").show()
                $(".col-md-offset-1").hide()
                $(".apkdel").hide();
                $(".ssa").remove()
            }else {
                alert("删除失败")
            }
        })
    })
    $(function (){
        backBtn = $("#back");
        backBtn.on("click",function(){
            //alert("view : "+referer);
            if(referer != undefined
                && null != referer
                && "" != referer
                && "null" != referer
                && referer.length > 4){
                window.location.href = referer;
            }else{
                history.back(-1);
            }
        });

    })

</script>
</html>
